package com.ilink.groundservice.entity.VO;

/**
 * <h3>i-scene</h3>
 *
 * @Description <p>通用返回值VO</p>
 * @Author yuhe zhu
 * @Date 2025-07-08 14:33
 **/
public class ResponseVO<T> {
    private int code;       // 状态码（例如：200成功，500失败）
    private String message; // 提示信息
    private T data;         // 返回的数据（泛型）

    // 构造方法
    public ResponseVO(int code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

    // 快速生成成功响应
    public static <T> ResponseVO<T> success(T data) {
        return new ResponseVO<>(200, "success", data);
    }

    // 快速生成失败响应
    public static <T> ResponseVO<T> fail(int code, String message) {
        return new ResponseVO<>(code, message, null);
    }
    //带data的失败响应
    public static <T> ResponseVO<T> fail(int code, String message, T data) {
        return new ResponseVO<>(code, message, data);
    }
    //只有msg的失败响应
    public static <T> ResponseVO<T> fail(String message) {
        return new ResponseVO<>(500, message, null);
    }
    //带msg的成功响应
    public static <T> ResponseVO<T> success(String message, T data) {
        return new ResponseVO<>(200, message, data);
    }

    public static ResponseVO success() {
        return new ResponseVO<>(200, "success", null);
    }

    // Getter & Setter
    public int getCode() {
        return code;
    }
    public void setCode(int code) {
        this.code = code;
    }
    public String getMessage() {
        return message;
    }
    public void setMessage(String message) {
        this.message = message;
    }
    public T getData() {
        return data;
    }
    public void setData(T data) {
        this.data = data;
    }
}